import time
import logging

class SwipeTool():
    def __init__(self,driver):
        self.driver=driver
        window_size = self.driver.get_window_size()
        print(window_size)
        self.w = window_size['width']
        self.h = window_size['height']

    #向上滑动
    def get_on(self):
        driver=self.driver
        driver.swipe(0.5 * self.w, 0.7 * self.h, 0.5 * self.w, 0.2 * self.h, 200)

    #向下滑动
    def get_down(self):
        driver = self.driver
        driver.swipe(0.5 * self.w,0.1* self.h,0.5 * self.w,0.9 * self.h,200)

    #向右滑动
    def get_right(self):
        driver = self.driver
        driver.swipe(0.1* self.w,0.5 *self.h,0.9 *self.w,0.5 *self.h,200)

    #向左滑动
    def get_left(self):
        driver = self.driver
        driver.swipe(0.9*self.w,0.35 *self.h,0.1* self.w,0.35 *self.h,200)

    def mobile_page_swip(self,start_x=0.5, start_y=3/4, end_y=1/6):
        '''
        页面上下滑动
        :return:
        '''



        x1 = int(self.w * start_x)
        y1 = int(self.h * start_y)
        y2 = int(self.h * end_y)
        time.sleep(4)
        self.driver.swipe(x1, y1, x1, y2, 1000)
        logging.info('向上滑动')
